#include<glib.h>
#include<pthread.h>

void NewThreadCreate(gpointer data, gpointer user_data){
	g_print("data is: %s\n",(gchar *)data);	
	g_print("user_data is: %s\n============================\n",(gchar *)user_data);	
}
int main(int argc,char * argv[]){
	GThreadPool* thread_pool;
	GError *error = NULL;
    thread_pool = g_thread_pool_new(NewThreadCreate,NULL,10,TRUE,&error);
	if(thread_pool == NULL)
		g_critical("%s\n",error->message);
	int count = 0;
	for(count;count<5;count++){
		//g_strdup_printf("%d",count);
		gchar *teststr = g_strdup_printf("value is: %d",count);
		//teststr = (gchar *)g_malloc(25);
		//g_sprintf(teststr," value is: %d",count);
		g_usleep(1000);
		g_thread_pool_push(thread_pool,(gpointer)teststr,&error);
	}
	/*if(g_thread_pool_push(thread_pool,(gpointer)"test",&error)){
		g_print("yes\n");
	}*/
	//g_thread_pool_set_max_threads(thread_pool,10,&error);
	int g_thread_num =  g_thread_pool_get_max_threads(thread_pool);
	g_print("Max number in the pthread pool: %d\n", g_thread_num);
	g_usleep(100000);
	return (0);
}
